package com.work.vo.main;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.work.utils.BigDecimalSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.tool.utils.Func;

import java.math.BigDecimal;

/**
 * 综合统计退关台账VO
 *
 * @author ：dujianyu
 * @since ：Created in 2024/7/5 13:30
 */
@Data
public class RetreatSetStatVO {

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(name = "货运船ID",notes = "")
    private Long transportShipId ;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(name = "货运舱单ID",notes = "")
    private Long transportBillId ;

    @ApiModelProperty(value = "船名")
    private String shipNameZh;

    @ApiModelProperty(value = "航次")
    private String voyage;

    @ApiModelProperty(value = "来源船信息")
    private String shipInfo;

    public String getShipInfo() {
        if (Func.isNull(shipNameZh) || Func.isNull(voyage)) {
            return "";
        }
        return shipNameZh + "/" + voyage;
    }

    @ApiModelProperty(value = "单号")
    private String billNo;

    @ApiModelProperty(value = "货名")
    private String billCargoTypeName;

    @ApiModelProperty(value = "包装")
    private String packageTypeName;

    @ApiModelProperty(name = "退关设置件数",notes = "")
    private Integer retreatSetPiece ;

    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(name = "退关设置吨数",notes = "")
    private BigDecimal retreatSetTon ;

    @ApiModelProperty(value = "退关设置件吨")
    private String retreatSetPieceTonInfo;

    public String getRetreatSetPieceTonInfo() {
        if (Func.isNull(retreatSetPiece) || Func.isNull(retreatSetTon)) {
            return "";
        }
        return retreatSetPiece + "/" + retreatSetTon.stripTrailingZeros().toPlainString();
    }

    @ApiModelProperty(name = "提货件数",notes = "")
    private Integer allOutPiece;

    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(name = "提货吨数",notes = "")
    private BigDecimal allOutTon;

    @ApiModelProperty(value = "退关设置件吨")
    private String allOutPieceTonInfo;

    public String getAllOutPieceTonInfo() {
        if (Func.isNull(allOutPiece) || Func.isNull(allOutTon)) {
            return "";
        }
        return allOutPiece + "/" + allOutTon.stripTrailingZeros().toPlainString();
    }

    @ApiModelProperty(name = "结余件数",notes = "")
    private Integer leftPiece ;

    public Integer getLeftPiece() {
        if (Func.isNull(retreatSetPiece) || Func.isNull(allOutPiece)) {
            return null;
        }
        return retreatSetPiece - allOutPiece;
    }

    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(name = "结余吨数",notes = "")
    private BigDecimal leftTon ;

    public BigDecimal getLeftTon() {
        if (Func.isNull(retreatSetTon) || Func.isNull(allOutTon)) {
            return null;
        }
        return retreatSetTon.subtract(allOutTon);
    }

    @ApiModelProperty(value = "结余件吨")
    private String leftPieceTonInfo;

    public String getLeftPieceTonInfo() {
        if (Func.isNull(allOutPiece) || Func.isNull(allOutTon)) {
            return "";
        }
        if (Func.isNull(retreatSetPiece) || Func.isNull(retreatSetTon)) {
            return "";
        }
        return (retreatSetPiece - allOutPiece) + "/" + retreatSetTon.subtract(allOutTon).stripTrailingZeros().toPlainString();
    }
}
